{% include '/templates/admin_header.html' %}
<!-- Content - Existing Platforms -->
<div id="content" class="flex">
  <h1>zerodyproject-d Platforms</h1>
  <div id="server-status">
    <div class="module" id="changelist">
      <form id="list-form" action="" method="post" name="delete_assets">
        <div class="results">
          <table id="result_list">
            <thead>
              <tr>
                <th scope="col" class="sortable">
                  <div class="text">
                    <a href="?o=1.-1">ID</a>
                  </div>
                  <div class="clear"></div>
                </th>
                <th scope="col" class="sortable"><div class="text">Name</div></th>
                <th scope="col" class="sortable"><div class="text">version</div></th>
                <th scope="col" class="sortable"><div class="text">URL</div></th>
              </tr>
            </thead>
            <tbody>
              {% for platform in platforms %}
              <tr class="row{{ platform.index % 2 }}">
                <th><a href="/admin/platforms/{{platform.id}}">{{platform.id}}</a></th>
                <td>{{platform.name}}</td>
                <td>{{platform.version}}</td>
                <td>{{platform.url}}</td>
              </tr>
              {% endfor %}
            </tbody>
          </table>
        </div>
      </form>
    </div>
  </div>
</div>
<!-- End Content - Existing Platforms -->

{% if platform %}

<!-- Content - Modify Platform -->
<script type="text/javascript">
	function validateForm() {
		if (document.modifying_form.app_version.value == ""
				|| document.modifying_form.asset_version.value == ""
				|| document.modifying_form.url.value == "") {
			alert("Required fields must be filled out!");
			return false;
		}

		return true;
	}
</script>

<form enctype="multipart/form-data" onsubmit="return(validateForm());" action="/admin/platforms" method="post" name="modifying_form">
  <div id="content" class="flex">
    <h1>Modify platform</h1>
    <div id="mod-platform">
      <fieldset class="module aligned ">
        <div class="form-row field-name">
          <div>
            <label for="id_name" class="required">Name:</label> <input id="id_name" type="text" class="vTextField" value="{{platform.name}}" name="name" maxlength="32" readonly />
          </div>
        </div>
        <div class="form-row field-application-version">
          <div>
            <label for="id_version" class="required">Application version:</label> <input id="id_version" type="number" class="vIntegerField" value="{{platform.version}}" name="version" maxlength="9999" />
          </div>
        </div>
        <div class="form-row field-url">
          <div>
            <label for="id_url" class="required">URL:</label> <input id="id_url" type="text" class="vTextField" value="{{platform.url}}" name="url" maxlength="128" />
          </div>
        </div>

        <div class="submit-row">
          <p class="backward-box">
            <a href="/admin/">Back</a>
          </p>
          <input type="submit" value="Save" class="default" name="_save" />
        </div>
      </fieldset>
    </div>
  </div>
</form>
{% else %}
<div id="content" class="flex">
  <div class="submit-row">
    <p class="backward-box">
      <a href="/admin/">Back</a>
    </p>
  </div>
</div>
{% endif %}
<!-- End Content - Modify Platform -->
{% include '/templates/admin_footer.html' %}

